/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server;

import RemoteObjects.MethodImplement;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
/**
 *
 * @author pbal
 */
public class RMIServer {
    
    private String serverName ="";
    private String hostName ="";
    private String port ="";
    protected  String url="";
    
    protected RMIServer(String serverName, String hostName, String port) { 
        this.hostName = hostName;
        this.port = port;
        this.serverName = serverName;   
    }
    
    public RMIServer() {}
    
    public void runServerRMI() throws IllegalArgumentException, 
                                       NotBoundException,
                                       RemoteException {
        MethodImplement causeRemoteObject = new MethodImplement();
        System.out.println("Server running: rmi://localhost:9020/RMIServer");
        Registry registryObject = LocateRegistry.createRegistry(Integer.parseInt(port, 10));
        registryObject.rebind(serverName, causeRemoteObject);
    }
    
    public String getUrlServer(String url) {
        return this.url =url;
    }
}